package com.mobileClientKernel.android.commonLayer;

import android.content.Context;

import java.io.IOException;
import java.io.InputStream;

public class FileOperator {
    /**
     * 读取asset 目录下的文件
     * @param context
     * @param filename
     * @return
     */
    public static String readAssetFile(Context context, String filename) {

        try {
            InputStream inputStream = context.getAssets().open(filename);
            int size = inputStream.available();
            byte[] buffer = new byte[size];
            inputStream.read(buffer);
            inputStream.close();
            String result = new String(buffer);
            return result;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }
}
